package cn.edu.djtu.fw.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.djtu.fw.dao.PARM_DICMapper;
import cn.edu.djtu.fw.model.Car;
import cn.edu.djtu.fw.model.Goods;
import cn.edu.djtu.fw.model.Lost;
import cn.edu.djtu.fw.model.News;
import cn.edu.djtu.fw.model.PARM_DIC;
import cn.edu.djtu.fw.service.CarServiceI;
import cn.edu.djtu.fw.service.GoodsServiceI;
import cn.edu.djtu.fw.service.LostServiceI;
import cn.edu.djtu.fw.service.NewsServiceI;
import cn.edu.djtu.fw.service.SystemServiceI;

@Service("systemService")
public class SystemServiceImpl implements SystemServiceI {
	private NewsServiceI newsService;
	private LostServiceI lostService;
	private GoodsServiceI goodsService;
	private CarServiceI carService;
	private PARM_DICMapper parmdicMapper;

	@SuppressWarnings("unchecked")
	@Override
	public void refreshApplication(Map<String, Object> application) {
		List<News> index_news = (List<News>) newsService.getAllNews(1, 10, null).get("rows");
		application.put("index_news", index_news);

		List<Lost> index_lost = (List<Lost>) lostService.getAllLost(1, 10, null).get("rows");
		application.put("index_lost", index_lost);

		// Lost lost = new Lost();
		// List<Lost> s_lost = (List<Lost>) lostService.getAllLost(1, 10, lost).get("rows");
		// application.put("s_lost", s_lost);

		List<Goods> index_goods = (List<Goods>) goodsService.getAllGoods(1, 20, null).get("rows");
		application.put("index_goods", index_goods);

		// Goods goods = new Goods();
		// List<Goods> s_goods = (List<Goods>) goodsService.getAllGoods(1, 5, goods).get("rows");
		// application.put("s_goods", s_goods);

		List<Car> index_car = (List<Car>) carService.getAllCar(1, 20, null).get("rows");
		application.put("index_car", index_car);

		// Car car = new Car();
		// List<Car> s_car = (List<Car>) carService.getAllCar(1, 15, car).get("rows");
		// application.put("s_car", s_car);
	}

	public NewsServiceI getNewsService() {
		return newsService;
	}

	@Autowired
	public void setNewsService(NewsServiceI newsService) {
		this.newsService = newsService;
	}

	public LostServiceI getLostService() {
		return lostService;
	}

	@Autowired
	public void setLostService(LostServiceI lostService) {
		this.lostService = lostService;
	}

	public GoodsServiceI getGoodsService() {
		return goodsService;
	}

	@Autowired
	public void setGoodsService(GoodsServiceI goodsService) {
		this.goodsService = goodsService;
	}

	public CarServiceI getCarService() {
		return carService;
	}

	@Autowired
	public void setCarService(CarServiceI carService) {
		this.carService = carService;
	}

	public PARM_DICMapper getParmdicMapper() {
		return parmdicMapper;
	}

	@Autowired
	public void setParmdicMapper(PARM_DICMapper parmdicMapper) {
		this.parmdicMapper = parmdicMapper;
	}

	@Override
	public List<String> getParmDicKeyName() {
		return parmdicMapper.getAllKeyName();
	}
	@Override
	public List<PARM_DIC> initParmDic(String s){
		return parmdicMapper.getParmDicByKeyName(s);
	}
}
